View
Integration of MobaiBiometric View with plain camera feed
This example shows how to integrate the Biometric Capture Session into your project. The Biometric Capture Session extracts a frame collection from the camera preview.
Add the Capture Session .xcframework inside the project. Link to guide on how to integrate the library inside the project https://www.simpleswiftguide.com/how-to-add-xcframework-to-xcode-project
Create View inside ViewController.
After finishing the import of .xcframework inside the project, you can import the library inside the swift file.
import MobaiBiometric
In the UI for this example app, we use the following:
Create view
private var mbCaptureSessionView: MBCaptureSessionView
Initialisation view with MBCaptureSessionOptions
public init() {
self.options = MBCaptureSessionOptions()
self.mbCaptureSessionView = MBCaptureSessionView(options: self.options)
}
Setup View Constraints
view.addSubview(takePictureButton)
NSLayoutConstraint.activate([
mbCaptureSessionView.topAnchor.constraint(equalTo: view.topAnchor),
mbCaptureSessionView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
mbCaptureSessionView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
mbCaptureSessionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
Starts Camera if camera permissions are granted
public override func viewWillAppear(_ animated: Bool) {
mbCaptureSessionView.onStartCapturing()
}
Stop Capturing
public override func viewWillDisappear(_ animated: Bool) {
mbCaptureSessionView.onStopCapturing()
}
Adding delegate and implementing the delegate inside View Controller
mbCaptureSessionView.delegate = self
extension ExampleViewController: MBCaptureSessionDelegate { }
Delegate
onInitializing Is executed when the camera it's started successfully
func onInitializing() { }
onValidation gives you data about the face position @param faceStatus is an enum that sends information about the face
func onValidation(_ status: DetectedFaceStatus)
onCountDown tells the time count down before capturing the image(This method is activated when you are using Automatic Capturing) @param time returns seconds of countdown in UI
func onCountDown(time: Int)
onCapturing is when the user starts capturing the image process
func onCapturing()
onSuccess is executed for MBCaptureSession class when the capture session is successfully finished @param result contains a list of frames.
func onSuccess(result: MBCaptureSessionResult)
onFailure is executed for MBCaptureSessionService class when the camera can not be @param error describes whether there is a camera or face failure
func onFailure(error: MBCaptureSessionError)